package com.clw.dao;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Properties;

import com.clw.bean.BaoJingCheLiang;




public class BaoJingCheLiangDao {
	public Map<String, Object> query() {
		List<String> baojingcheliangArr1 = new ArrayList<String>();
		List<Integer> baojingcheliangArr2 = new ArrayList<Integer>();
		Map<String, Object> map = new HashMap<String, Object>();
		Connection conn = null;
		Properties properties = new Properties();
		properties.setProperty("user", "root");
		properties.setProperty("password", "123456");
		properties.setProperty("useSSL", "false");
		properties.setProperty("autoReconnect", "true");

		try {
			Class.forName("com.mysql.jdbc.Driver");

			conn = DriverManager.getConnection(
					"jdbc:mysql://localhost:3306/bigdata_clw?useUnicode=true&characterEncoding=utf-8", properties);
			PreparedStatement stmt = conn.prepareStatement("SELECT * FROM t_baojingcheliang");
			ResultSet rs = stmt.executeQuery();

			while (rs.next()) {

				baojingcheliangArr1.add(rs.getString("name"));
				baojingcheliangArr2.add(rs.getInt("value"));

			}
			conn.close();
		} catch (SQLException e) {
			e.printStackTrace();
		} catch (ClassNotFoundException e) {
			// TODO: handle exception
			e.printStackTrace();
		}
		map.put("name", baojingcheliangArr1);
		map.put("value", baojingcheliangArr2);
		return map;
	}
}
